package com.central.scheduler.remote.command;

import com.central.scheduler.common.utils.JSONUtils;

import java.io.Serializable;

/**
 * @author Tindy
 * @date 2022/1/5
 * @describe
 * db task final result response command
 */
public class StateEventResponseCommand implements Serializable {

    private String key;
    private int status;

    public StateEventResponseCommand() {
        super();
    }

    public StateEventResponseCommand(int status, String key) {
        this.status = status;
        this.key = key;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    /**
     * package response command
     *
     * @return command
     */
    public Command convert2Command() {
        Command command = new Command();
        command.setType(CommandType.DB_TASK_RESPONSE);
        byte[] body = JSONUtils.toJsonByteArray(this);
        command.setBody(body);
        return command;
    }

    @Override
    public String toString() {
        return "StateEventResponseCommand{"
                + "key=" + key
                + ", status=" + status
                + '}';
    }

}
